package me.frank.security.support;

import me.frank.security.enums.ErrorCodeEnum;

/**
 * @Author Frank Wang
 * @Description:
 * @Date 2018/12/11 17:52
 */
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 7805721319295260114L;
    /**
     * 异常码
     */
    protected int code;


    public BusinessException() {
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(int code, String msgFormat, Object... args) {
        super(String.format(msgFormat, args));
        this.code = code;
    }

    public BusinessException(ErrorCodeEnum codeEnum, Object... args) {
        super(String.format(codeEnum.msg(), args));
        this.code = codeEnum.code();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
